package com.novunda.platform.web.page;

import com.gargoylesoftware.htmlunit.html.XHtmlPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

/**
 *
 * @author linfeng
 */
public abstract class AbstractPage {

    protected WebDriver driver;

    @FindBy(css = "label.error, .alert-error")
    private WebElement errors;

    public AbstractPage(WebDriver driver) {
        setDriver(driver);
    }

    public void setDriver(WebDriver driver) {
        this.driver = driver;
    }

    public String getErrors() {
        return errors.getText();
    }

    public static void get(WebDriver driver, String relativeUrl) {
        String url = System.getProperty("geb.build.baseUrl", "http://localhost/") + relativeUrl;
        driver.get(url);
    }

}